<template>
  <el-card class="monitor-task-list">
    <tag-content-header setting @toolFun="toolFun" :settingData="columns">
      <template #title>
        <span class="title-text">定时监控列表</span>
      </template>
    </tag-content-header>
    <tag-table
      ref="table"
      @refresh="getList"
      :data="dataList"
      :loading="loading"
      :columns="columns"
      :params="params"
      :total="totalSize"
    >
      <template #operation="{ scope }">
        <div class="operation-button-box">
          <el-tooltip effect="dark" content="下载" placement="top" :enterable="false">
            <icon-svg name="iconMonitorDownload" class="svg-view" @click.native="handleDownload(scope.row)"></icon-svg>
          </el-tooltip>
        </div>
      </template>
    </tag-table>
  </el-card>
</template>

<script>
export default {
  data() {
    return {
      dataList: [],
      loading: false,
      columns: [
        {
          show: true,
          label: '序号',
          prop: 'indexNum',
          align: 'right',
          width: 100
        },
        {
          show: true,
          label: '版本文件名',
          prop: 'originalFilename',
          align: 'center'
        },
        {
          show: true,
          label: '更新时间',
          prop: 'updateTm',
          align: 'center'
        },
        {
          show: 'fixed',
          label: '操作',
          prop: 'operation',
          align: 'center',
          width: 200
        }
      ],
      params: {
        ascs: [],
        descs: [],
        currentPageNum: 1,
        pageSize: 10,
        queryParams: {},
        descPriority: false
      },
      totalSize: 0,
      selectAsset: {}
    }
  },
  methods: {
    getList() {
      this.loading = true
      this.$ajax({
        url: this.$ajax.setUrl('tag/tagWarningConfig/getTimeMonitoring'),
        method: 'get',
        params: this.$ajax.setParams(this.params)
      }).then(({ data }) => {
        if (data && data.code === '0') {
          this.dataList = data.data.records
          this.totalSize = data.data.totalSize
        } else {
          this.$message.error(data.data || data.msg)
        }
        this.loading = false
      })
    },
    toolFun(operation) {
      switch (operation) {
        case 'refresh':
          // 刷新动作
          this.getList()
          break
      }
    },
    handleDownload(scope) {
      this.$dlFile(scope.dataQualityFiledId)
      this.$dlFile(scope.dataWarningFiledId)
    }
  }
}
</script>

<style lang="scss">
.monitor-task-list {
  margin-top: 20px;
}
</style>
